<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>

    <style>
        .demo{
            background-color: purple;
        }
    </style>
</head>
<body>
    <div id="root">
        <button id="btn">点击创建一个输入框</button>

        <script type="text/javascript">
            const btn = document.getElementById('btn')
            btn.onclick=()=>{
                const input = document.createElement('input')
                input.className='demo'
                input.value=10
                input.onclick= ()=>{alert(1)}
                
                document.body.appendChild(input)
                // 需要先创建才有==注意执行时机
                input.focus()
                input.parentElement.style.backgroundColor='red'
                console.log(input.parentElement)
            }
        </script>
    </div>
</body>
</html>